<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<h:outputStylesheet library="css" name="fonte.css" />
	<title>Consulta Pessoa Jurídica</title>
</h:head>
	<h:body>
		<h:form>
				<h:panelGrid columns="3" columnClasses="label" cellspacing="3">
					<h:panelGrid>
						Fantasia:
						<p:inputText size="60" value="#{pesquisaPessoaJuridicaBean.pessoaJuridica.fantasia}" />					
					</h:panelGrid>
					<h:panelGrid>
						CNPJ:
						<p:inputText size="20" value="#{pesquisaPessoaJuridicaBean.pessoaJuridica.cnpj}" />					
					</h:panelGrid>

					<h:panelGrid>
						<p:commandButton id="btnPesquisar" value="Pesquisar" update="dataPesquisa" />
					</h:panelGrid>
				</h:panelGrid>
				<h:panelGrid columns="2" columnClasses="label" cellspacing="3">
					<h:panelGrid>
						Razão Social:
						<p:inputText size="60" value="#{pesquisaPessoaJuridicaBean.pessoaJuridica.razaoSocial}" />					
					</h:panelGrid>
					<h:panelGrid>
						Inscr. Estadual:
						<p:inputText size="20" value="#{pesquisaPessoaJuridicaBean.pessoaJuridica.ie}" />					
					</h:panelGrid>
				</h:panelGrid>
				
				<p:blockUI block="dataPesquisa" trigger="btnPesquisar" />
				<p:dataTable id="dataPesquisa" value="#{pesquisaPessoaJuridicaBean.pessoaJuridicaList}" var="pesPJ" resizableColumns="true"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15" lazy="true" border="1" paginatorPosition="bottom" cellpadding="2" cellspacing="0"
					paginator="true" rows="10" rowKey="pesPJ.idPessoa">

					<f:facet name="header">Pessoas Jurídica Cadastradas</f:facet>

					<p:column headerText="Codigo">
						<h:outputText value="#{pesPJ.idPessoa}" />
					</p:column>

					<p:column headerText="Nome Fantasia">
						<h:outputText value="#{pesPJ.fantasia}" />
					</p:column>
					
					<p:column headerText="Razão Social">
						<h:outputText value="#{pesPJ.razaoSocial}" />
					</p:column>
					
					<p:column headerText="Status">
						<h:outputText value="#{pesPJ.status}" />
					</p:column>
					
					<p:column headerText="Natureza Pessoa">
						<h:outputText value="#{pesPJ.naturezaPessoa}" />
					</p:column>

					<p:column headerText="Tipo Pessoa Jurídica">
						<h:outputText value="#{pesPJ.tipoPessoaJuridica}" />
					</p:column>					

					<p:column headerText="CNPJ">
						<h:outputText value="#{pesPJ.cnpj}" />
					</p:column>

					<p:column headerText="Inscr. Estadual">
						<h:outputText value="#{pesPJ.ie}" />
					</p:column>
					
					<p:column headerText="CNAE">
						<h:outputText value="#{pesPJ.cnae}" />
					</p:column>					
					<p:column headerText="Selecionar" style="width: 50px; text-align: center">
		    			<p:commandButton icon="ui-icon-check" title="Selecionar"
		    				action="#{pesquisaPessoaJuridicaBean.selecionaPessoa(pesPJ)}"
		    				process="@this" />
					</p:column>
				</p:dataTable>
				<p:blockUI block="dataPesquisa" trigger="dataPesquisa">
       				LOADING<br />
					<p:graphicImage name="ajaxloader.gif" />
				</p:blockUI>
		</h:form>
	</h:body>
</html>